set terminal pdf
set output "ellipse.pdf"

# 读取椭圆参数
datafile = "dimension.txt"
stats datafile nooutput
parameters = system('cat '.datafile)

# 计算三轴长
a = word(parameters, 1)
b = word(parameters, 2)
c = word(parameters, 3)

# 绘制椭圆
set parametric
set urange [0:2*pi]
set vrange [0:pi]
set isosamples 100, 50
set hidden3d
set view 60, 30, 1, 1
set title "Three-dimensional Ellipse"
set xlabel "X-axis"
set ylabel "Y-axis"
set zlabel "Z-axis"
splot a*cos(u)*sin(v), b*sin(u)*sin(v), c*cos(v)

